import javax.swing.*;
import javax.swing.text.IconView;
import java.awt.*;

/*
swing 底层控件--JLabel
* */
public class MyPanel extends JPanel {
    public MyPanel() {

        JLabel jLabel = new JLabel();
        jLabel.setText("我是jLabel0");
        jLabel.setForeground(new Color(0xff));
        JLabel jLabel1 = new JLabel("我是Label1");
        jLabel1.setForeground(new Color(0xaa));
        jLabel1.setFont(getFont());//设置字体,得到平台默认字体
        JLabel jLabel2 = new JLabel("我是jLabel2");
        jLabel2.setToolTipText("fff");
        jLabel2.setForeground(new Color(0xeeff));
        jLabel2.setFont(new Font("宋体",0,18));//font-name,font-style,font-size
        jLabel2.setToolTipText("https://www.baidu.com");//设置提示，悬停时触发

        add(jLabel);
        add(jLabel1);
        add(jLabel2);

    }
}

class Test{

    public static void main(String[] args) {
        JFrame jFrame = new JFrame("测试第三级组件");
        jFrame.setLocation(300,400);
        jFrame.setSize(400,400);
        jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        jFrame.setLocationRelativeTo(null);
        jFrame.setLayout(new FlowLayout());

        MyPanel myPanel = new MyPanel();
        jFrame.add(myPanel);
        jFrame.setVisible(true);
    }

}
